/* 
 * File:   main.c
 * Author: jadsin
 *
 * Created on July 19, 2011, 10:05 PM
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>

//client
int main()
{
	int sockfd;
	int len;
	struct sockaddr_in addr;
	int result;
	char str[6];

	sockfd = socket(AF_INET,SOCK_STREAM,0);
	
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	addr.sin_port = htons(9000);
	bzero(&(addr.sin_zero),8);
	len = sizeof(addr);

	result = connect(sockfd,(struct sockaddr *)&addr,len);
	if(result == -1)
	{
		perror("client:");
		exit(1);
	}

	read(sockfd,str,6);
	printf("%s\n",str);
	exit(0);
}
